package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.InEngineeringOrderListForMapView;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringOrderListForMapModel;
import com.cloudsigns.factorymanager2.engineering.model.InEngineeringOrderListForMapModel;

import java.util.List;

/**
 * Created by tony on 2018/5/3.
 */

public class EngineeringOrderListForMapPresenter {
    private InEngineeringOrderListForMapView view;
    private InEngineeringOrderListForMapModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringOrderListForMapPresenter(InEngineeringOrderListForMapView view) {
        this.view = view;
        this.model = new EngineeringOrderListForMapModel();
    }

    public void getEngineeringOrderList() {


        model.getEngineeringOrderListForMap(new EngineeringOrderListForMapModel.OnEngineeringOrderListForMapListener() {
            @Override
            public void getEngineeringOrderListForMapSuccessed(final List<OrderParentBean> allOrderList,final List<OrderParentBean> matenanceOrderList,final List<OrderParentBean> engineeringManageOrderList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringOrderListForMapSuccessed(allOrderList,matenanceOrderList,engineeringManageOrderList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getEngineeringOrderListForMapFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringOrderListForMapFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
